<template>
	<view class="appPage">
		<!-- <loadingC v-if="pageLoading"></loadingC> -->
		<button class="btn" @click="trigger('1')">开锁(道里店)</button>
		<button class="btn" @click="trigger('2')">开锁(南岗店)</button>
		<button class="btn" @click="trigger('3')">开锁(哈尔滨店)</button>
	</view>
</template>

<script>
	import {
		apiOpendoork
	} from '@/api/common.js'
	export default {
		data() {
			return {
				loading: false,
				dev_id: '39255',
				dev_pwd: 'ag639',
				clock: 'close',
				url:''
			}
		},
		filters: {

		},
		onLoad(option) {
			this.pageLoading = true
			setTimeout(() => {
				this.pageLoading = false
			}, 1000)
		},
		onShow() {
			this.clock = 'close'
		},
		methods: {

			trigger(str) {
				if (this.clock == 'opening' || this.clock == 'open') return false
				this.loading = true
				this.clock = 'opening'
				if (str == 1) {
					this.dev_id = '39255'
					this.dev_pwd = 'ag639'
					this.url= 'https://chuku.snowmetal.cn'
				} else if (str == 2) {
					this.dev_id = '39292'
					this.dev_pwd = 'mar68'
					this.url= 'https://chuku2.snowmetal.cn'
				}else if (str == 3) {
					this.dev_id = '39430'
					this.dev_pwd = 'wan69'
					this.url= 'https://chuku3.snowmetal.cn'
				}
				apiOpendoork(this.url +
					'/index/user/opendoor.html', {
						dev_id: this.dev_id,
						dev_pwd: this.dev_pwd
					}).then(res => {
					if (res == 'success') {
						uni.showToast({
							title: '已开锁',
							duration: 2000,
							mask: true
						})
						this.clock = 'close'
						this.loading = false

						// setTimeout(() => {
						// 	uni.navigateTo({
						// 		url: '/pages/input/index'
						// 	})

						// }, 2000)
					} else {
						this.clock = 'close'
						this.loading = false
						uni.showToast({
							title: '开锁失败，请重试（或联系管理员）',
							icon: 'none',
							duration: 3000,
							mask: true
						})
					}

				})

			}
		}
	}
</script>

<style scoped lang="scss">
	.appPage {
		width: 100%;
		height: 100vh;
		background-color: #f5f5f5;
		// display: flex;
		// flex-direction: column;
		// align-items: center;
		justify-content: center;
		padding-top: 200rpx;
		

		.btn {
			width: 710rpx;
			background-color: #6ac4c4;
			color: #000;
			font-weight: bold;
			font-size:36rpx;
			padding: 20rpx 0;
			margin-top: 40rpx;
			text-align: center;
			margin-left: 20rpx;
			border-radius: 20rpx;
			margin-top: 50rpx;
		}



	}
</style>